Add TCGTracking pricing integration and scripts#1428
Open
FalconChipp wants to merge 2 commits into
Open
Conversation
Introduce TCGTracking-based pricing pipeline and server support. - Add new scripts: scripts/preloadTCGTracking.ts (caches TCGTracking set pricing), scripts/updatePricingFromTCGTracking.ts (resolves cached pricing to a resolved-pricing artifact), and scripts/utils-data/tcgtracking.ts (helpers, fetcher, cache path helpers, category mapping, import URL fix). - Extend scripts/preloadTCGPlayer.ts to also download TCGCSV prices into var/models/tcgplayer/prices as a fallback. - Add set ID override support, daily cache freshness checks, polite fetch delays, failure reporting (var/reports/tcgtracking-preload-failures.json), and --strict/--apply flags for control. - New pricing resolver supports three modes via PRICING_SOURCE: tcgtracking (default), tcgcsv (old fallback), tcgtracking-only; updatePricingFromTCGTracking supports dry-run and apply and writes var/models/tcgtracking/resolved-pricing.json when applied. - Wire the server to use the new provider: add server/src/libs/providers/tcgplayer/tcgtracking.ts and load it by default in server/src/libs/providers/tcgplayer/index.ts unless official credentials or PRICING_SOURCE=tcgcsv are present. Notes: The scripts do not mutate card source files or create/remap variants; caching filenames use existing TCGPlayer set IDs to remain compatible with existing data.
Add a unified pricing subsystem and updater: new files under scripts/pricing (cache, sources, tcgplayer, tcgtracking, types) and a top-level scripts/updatePricing.ts that scans card files, resolves prices from configured providers, and writes reports/debug artifacts. Implements a TTLCache, provider factory/ordering (TCGDEX_PRICING_SOURCES), TCGPlayer and TCGTracking providers with caching and inflight deduplication, and set ID overrides for TCGTracking. Remove legacy TCGTracking-specific preload/update scripts (scripts/preloadTCGTracking.ts and scripts/updatePricingFromTCGTracking.ts) and update package.json scripts to use pricing:update / pricing:update:debug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add TCGTracking as primary pricing source
This PR adds a provider-based pricing pipeline with TCGTracking as the primary source and the existing TCGPlayer/TCGCSV-backed source as fallback.
The source order is controlled by:
Supported values:
Background
The existing fallback pricing flow uses TCGCSV, which mirrors TCGPlayer data and is referred to as
tcgplayerthroughout the repo/server code.TCGCSV has recently been unreliable/unavailable for us, so this PR adds TCGTracking as the default pricing source while keeping the existing TCGPlayer/TCGCSV path available as a fallback.
What changed
New pricing provider system
Added:
This introduces a shared provider flow for resolving prices by existing
thirdParty.tcgplayerIDs.The first provider to return a price wins.
TCGTracking provider
The TCGTracking provider fetches set pricing lazily and caches it in memory per set during the run.
It uses:
/tcgapi/v1/{categoryId}/sets/{setId}/pricingPricing is resolved from:
Observed price types include:
The provider does not create, infer, or remap variants. It only uses existing card/variant
thirdParty.tcgplayerIDs.TCGPlayer fallback provider
The existing TCGPlayer/TCGCSV-backed pricing source remains available as the
tcgplayerprovider.This keeps backwards compatibility and allows unresolved TCGTracking prices to fall back to the previous source where possible.
Black Bolt set ID override
TCGTracking uses a different set ID for Black Bolt:
An override is included so pricing can be fetched from TCGTracking while still resolving against the existing TCGDex set ID.
New updater
Added:
This replaces the TCGTracking-specific proof-of-concept updater with a generic provider-based pricing update flow.
It supports reporting/debug output and does not mutate card source files.
Known fallback cases
TCGTracking does not currently expose pricing endpoints for:
These remain fallback cases.
Summary
This PR moves pricing to a provider-based flow:
existing thirdParty.tcgplayer ID ↓ configured pricing providers ↓ TCGTracking primary ↓ TCGPlayer/TCGCSV fallback ↓ resolved pricing/report output